Hệ thống quản lý hàng tồn kho trong php

1 <?php
2   session_start();
3
4   
if (!isset($_SESSION['username'])) {
5     $_SESSION[
'msg'] = "You must log in first";
6     header(
'location: login.php');
7   }
8   
if (isset($_GET['logout'])) {
9     session_destroy();
10     unset($_SESSION[
'username']);
11     header(
"location: login.php");
12   }
13 ?>
14 <?php

15
16
17 // initializing variables

18 $item_name =
"";
19 $item_price =
"";
20
21
22 // connect to the database

23 $db = mysqli_connect(
'localhost', 'root', '', 'inventory');
24 if
(mysqli_connect_errno())
25     {
26     echo
"Failed to connect to MySQL: " . mysqli_connect_error();
27     }

28
29 // Add item

30 if
(isset($_POST['add'])) {
31   
// receive all input values from the form
32   echo
"connect";
33   $item_name=mysqli_real_escape_string($db, $_POST[
'product_name']);
34   $item_price=mysqli_real_escape_string($db, $_POST[
'price']);
35   $quant=mysqli_real_escape_string($db, $_POST[
'quant']);
36   
37     $query =
"INSERT INTO product (product_name,price,quantity)
38               VALUES('$item_name','$item_price','$quant')"
;
39       
if(mysqli_query($db, $query))
40       {
41       echo
"<script>alert('Successfully stored');</script>";
42                 
43     }
44     
else{
45         echo
"<script>alert('Somthing wrong!!!');</script>";
46     }
47     
48     header(
'location: table.php');
49   
50 }
51 ?>
52 <!-->
53
54 <!DOCTYPE html>
55 <html>
56 <head>
57     <title>Add Item</title>
58     <link rel=
"stylesheet" type="text/css" href="style.css">
59     <link rel=
"stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
60 </head>
61 <body>
62 <form method=
"POST" class="form-inline" action="additem.php">
63   <div
class="form-group">
64     <label
for="name">Product Name</label>
65     <input type=
"text" class="form-control" name="product_name">
66     
67   </div>
68   <div
class="form-group">
69     <label
for="name">Price</label>
70     <input type=
"text" class="form-control" name="price">
71   </div>
72   <div>
73         <label
for="name">Quantity</label>
74         <input type=
"number" name="quant" id="quant" min="1" max="">
75     </div>
76   <button type=
"submit" class="btn btn-default" name="add">Add item</button>
77 </form>
78
79 <div>
80 <a href=
"table.php">Home</a>
81 </div>
82 </body>
83 </html>
84 <!-->


Gõ tìm kiếm nhanh...